\documentclass[11pt]{article} 
\usepackage[latin1]{inputenc} 
\usepackage[T1]{fontenc} 
\usepackage{fullpage} 
\usepackage{url} 
\usepackage{ocamldoc}
\begin{document}
\tableofcontents
\section{Module {\tt{XmlRpc}} : XmlRpc Light}
\label{module:XmlRpc}\index{XmlRpc@\verb`XmlRpc`}



    XmlRpc Light is a minimal XmlRpc client based on Xml Light and Ocamlnet.


    It provides a type for values, a client class with a simple calling
    interface, and low-level tools that can be used to implement a server.


    {\it (c) 2007 Dave Benjamin}



\ocamldocvspace{0.5cm}



High-level interface



Example: \begin{ocamldoccode}

    let rpc = new XmlRpc.client "http://localhost:8000" in
    let result = rpc#call "echo" [`String "hello!"] in
    print_endline (XmlRpc.dump result) 
\end{ocamldoccode}




\label{exception:XmlRpc.Error}\begin{ocamldoccode}
exception Error of (int * string)
\end{ocamldoccode}
\index{Error@\verb`Error`}
\begin{ocamldocdescription}
Raised for all errors including XmlRpc faults (code, string).


\end{ocamldocdescription}




\label{type:XmlRpc.value}\begin{ocamldoccode}
type value = [ `Array of value list
  | `Binary of string
  | `Boolean of bool
  | `DateTime of int * int * int * int * int * int * int
  | `Double of float
  | `Int of int
  | `String of string
  | `Struct of (string * value) list ] 
\end{ocamldoccode}
\index{value@\verb`value`}
\begin{ocamldocdescription}
Polymorphic variant type for XmlRpc values:\begin{itemize}
\item {\tt{`Array}}: An ordered list of values
\item {\tt{`Binary}}: A string containing binary data
\item {\tt{`Boolean}}: A boolean
\item {\tt{`DateTime}}: A date-time value
      (year, month, day, hour, minute, second, timezone offset in minutes)
\item {\tt{`Double}}: A floating-point value
\item {\tt{`Int}}: An integer
\item {\tt{`String}}: A string
\item {\tt{`Struct}}: An association list of (name, value) pairs
\end{itemize}

    Note that base64-encoding of {\tt{`Binary}} values is done automatically.
    You do not need to do the encoding yourself.


\end{ocamldocdescription}




\begin{ocamldoccode}
{\tt{class client : }}{\tt{string -> }}\end{ocamldoccode}
\label{class:XmlRpc.client}\index{client@\verb`client`}

\begin{ocamldocobjectend}


\label{val:XmlRpc.client.url}\begin{ocamldoccode}
val url : string
\end{ocamldoccode}
\index{url@\verb`url`}
\begin{ocamldocdescription}
Url of the remote XmlRpc server.


\end{ocamldocdescription}


\label{val:XmlRpc.client.useragent}\begin{ocamldoccode}
val mutable useragent : string
\end{ocamldoccode}
\index{useragent@\verb`useragent`}
\begin{ocamldocdescription}
User-agent to send in request headers.


\end{ocamldocdescription}


\label{val:XmlRpc.client.debug}\begin{ocamldoccode}
val mutable debug : bool
\end{ocamldoccode}
\index{debug@\verb`debug`}
\begin{ocamldocdescription}
If true, Xml messages will be printed to standard output.


\end{ocamldocdescription}


\label{method:XmlRpc.client.url}\begin{ocamldoccode}
method url : string
\end{ocamldoccode}
\index{url@\verb`url`}
\begin{ocamldocdescription}
Gets {\tt{url}}.


\end{ocamldocdescription}


\label{method:XmlRpc.client.useragent}\begin{ocamldoccode}
method useragent : string
\end{ocamldoccode}
\index{useragent@\verb`useragent`}
\begin{ocamldocdescription}
Gets {\tt{useragent}}.


\end{ocamldocdescription}


\label{method:XmlRpc.client.set-underscoreuseragent}\begin{ocamldoccode}
method set_useragent : string -> unit
\end{ocamldoccode}
\index{set-underscoreuseragent@\verb`set_useragent`}
\begin{ocamldocdescription}
Sets {\tt{useragent}}.


\end{ocamldocdescription}


\label{method:XmlRpc.client.debug}\begin{ocamldoccode}
method debug : bool
\end{ocamldoccode}
\index{debug@\verb`debug`}
\begin{ocamldocdescription}
Gets {\tt{debug}}.


\end{ocamldocdescription}


\label{method:XmlRpc.client.set-underscoredebug}\begin{ocamldoccode}
method set_debug : bool -> unit
\end{ocamldoccode}
\index{set-underscoredebug@\verb`set_debug`}
\begin{ocamldocdescription}
Sets {\tt{debug}}.


\end{ocamldocdescription}


\label{method:XmlRpc.client.set-underscorebase64-underscoreencode}\begin{ocamldoccode}
method set_base64_encode : (string -> string) -> unit
\end{ocamldoccode}
\index{set-underscorebase64-underscoreencode@\verb`set_base64_encode`}
\begin{ocamldocdescription}
Sets an alternate Base-64 binary encoding function.


\end{ocamldocdescription}


\label{method:XmlRpc.client.set-underscorebase64-underscoredecode}\begin{ocamldoccode}
method set_base64_decode : (string -> string) -> unit
\end{ocamldoccode}
\index{set-underscorebase64-underscoredecode@\verb`set_base64_decode`}
\begin{ocamldocdescription}
Sets an alternate Base-64 binary decoding function.


\end{ocamldocdescription}


\label{method:XmlRpc.client.set-underscoredatetime-underscoreencode}\begin{ocamldoccode}
method set_datetime_encode :
  (int * int * int * int * int * int * int -> string) -> unit
\end{ocamldoccode}
\index{set-underscoredatetime-underscoreencode@\verb`set_datetime_encode`}
\begin{ocamldocdescription}
Sets an alternate ISO-8601 date/time encoding function.


\end{ocamldocdescription}


\label{method:XmlRpc.client.set-underscoredatetime-underscoredecode}\begin{ocamldoccode}
method set_datetime_decode :
  (string -> int * int * int * int * int * int * int) -> unit
\end{ocamldoccode}
\index{set-underscoredatetime-underscoredecode@\verb`set_datetime_decode`}
\begin{ocamldocdescription}
Sets an alternate ISO-8601 date/time decoding function.


\end{ocamldocdescription}


\label{method:XmlRpc.client.call}\begin{ocamldoccode}
method call : string -> XmlRpc.value list -> XmlRpc.value
\end{ocamldoccode}
\index{call@\verb`call`}
\begin{ocamldocdescription}
{\tt{call name params}} invokes an XmlRpc method and returns the result,
      or raises {\tt{XmlRpc.Error}}[\ref{exception:XmlRpc.Error}] on error.


\end{ocamldocdescription}
\end{ocamldocobjectend}


\begin{ocamldocdescription}
Class for XmlRpc clients. Takes a single argument, the Url.


\end{ocamldocdescription}




Utility functions



\label{val:XmlRpc.dump}\begin{ocamldoccode}
val dump : value -> string
\end{ocamldoccode}
\index{dump@\verb`dump`}
\begin{ocamldocdescription}
Converts an XmlRpc value to a human-readable string for debugging.


\end{ocamldocdescription}




Low-level interface



\label{type:XmlRpc.message}\begin{ocamldoccode}
type message =
  | MethodCall of (string * value list)
  | MethodResponse of value
  | Fault of (int * string)
\end{ocamldoccode}
\index{message@\verb`message`}
\begin{ocamldocdescription}
Type for XmlRpc messages.


\end{ocamldocdescription}




\label{val:XmlRpc.message-underscoreof-underscorexml-underscoreelement}\begin{ocamldoccode}
val message_of_xml_element :
  ?base64_decode:(string -> string) ->
  ?datetime_decode:(string -> int * int * int * int * int * int * int) ->
  Xml.xml -> message
\end{ocamldoccode}
\index{message-underscoreof-underscorexml-underscoreelement@\verb`message_of_xml_element`}
\begin{ocamldocdescription}
Converts an Xml Light element to an XmlRpc message.


\end{ocamldocdescription}




\label{val:XmlRpc.xml-underscoreelement-underscoreof-underscoremessage}\begin{ocamldoccode}
val xml_element_of_message :
  ?base64_encode:(string -> string) ->
  ?datetime_encode:(int * int * int * int * int * int * int -> string) ->
  message -> Xml.xml
\end{ocamldoccode}
\index{xml-underscoreelement-underscoreof-underscoremessage@\verb`xml_element_of_message`}
\begin{ocamldocdescription}
Converts an XmlRpc message to an Xml Light element.


\end{ocamldocdescription}




\label{val:XmlRpc.value-underscoreof-underscorexml-underscoreelement}\begin{ocamldoccode}
val value_of_xml_element :
  ?base64_decode:(string -> string) ->
  ?datetime_decode:(string -> int * int * int * int * int * int * int) ->
  Xml.xml -> value
\end{ocamldoccode}
\index{value-underscoreof-underscorexml-underscoreelement@\verb`value_of_xml_element`}
\begin{ocamldocdescription}
Converts an Xml Light element to an XmlRpc value.


\end{ocamldocdescription}




\label{val:XmlRpc.xml-underscoreelement-underscoreof-underscorevalue}\begin{ocamldoccode}
val xml_element_of_value :
  ?base64_encode:(string -> string) ->
  ?datetime_encode:(int * int * int * int * int * int * int -> string) ->
  value -> Xml.xml
\end{ocamldoccode}
\index{xml-underscoreelement-underscoreof-underscorevalue@\verb`xml_element_of_value`}
\begin{ocamldocdescription}
Converts an XmlRpc value to an Xml Light element.


\end{ocamldocdescription}


\section{Module {\tt{XmlRpcBase64}} : Base64 codec.}
\label{module:XmlRpcBase64}\index{XmlRpcBase64@\verb`XmlRpcBase64`}



	8-bit characters are encoded into 6-bit ones using ASCII lookup tables.
	Default tables maps 0..63 values on characters A-Z, a-z, 0-9, '+' and '/'
	(in that order).



\ocamldocvspace{0.5cm}



\label{exception:XmlRpcBase64.Invalid-underscorechar}\begin{ocamldoccode}
exception Invalid_char
\end{ocamldoccode}
\index{Invalid-underscorechar@\verb`Invalid_char`}
\begin{ocamldocdescription}
This exception is raised when reading an invalid character
	from a base64 input.


\end{ocamldocdescription}




\label{exception:XmlRpcBase64.Invalid-underscoretable}\begin{ocamldoccode}
exception Invalid_table
\end{ocamldoccode}
\index{Invalid-underscoretable@\verb`Invalid_table`}
\begin{ocamldocdescription}
This exception is raised if the encoding or decoding table
	size is not correct.


\end{ocamldocdescription}




\label{type:XmlRpcBase64.encoding-underscoretable}\begin{ocamldoccode}
type encoding_table = char array 
\end{ocamldoccode}
\index{encoding-underscoretable@\verb`encoding_table`}
\begin{ocamldocdescription}
An encoding table maps integers 0..63 to the corresponding char.


\end{ocamldocdescription}




\label{type:XmlRpcBase64.decoding-underscoretable}\begin{ocamldoccode}
type decoding_table = int array 
\end{ocamldoccode}
\index{decoding-underscoretable@\verb`decoding_table`}
\begin{ocamldocdescription}
A decoding table maps chars 0..255 to the corresponding 0..63 value
 or -1 if the char is not accepted.


\end{ocamldocdescription}




\label{val:XmlRpcBase64.str-underscoreencode}\begin{ocamldoccode}
val str_encode : ?tbl:encoding_table -> string -> string
\end{ocamldoccode}
\index{str-underscoreencode@\verb`str_encode`}
\begin{ocamldocdescription}
Encode a string into Base64.


\end{ocamldocdescription}




\label{val:XmlRpcBase64.str-underscoredecode}\begin{ocamldoccode}
val str_decode : ?tbl:decoding_table -> string -> string
\end{ocamldoccode}
\index{str-underscoredecode@\verb`str_decode`}
\begin{ocamldocdescription}
Decode a string encoded into Base64, raise {\tt{Invalid\_char}} if a
	character in the input string is not a valid one.


\end{ocamldocdescription}




\label{val:XmlRpcBase64.encode}\begin{ocamldoccode}
val encode : ?tbl:encoding_table -> char Stream.t -> char Stream.t
\end{ocamldoccode}
\index{encode@\verb`encode`}
\begin{ocamldocdescription}
Generic base64 encoding over a character stream.


\end{ocamldocdescription}




\label{val:XmlRpcBase64.decode}\begin{ocamldoccode}
val decode : ?tbl:decoding_table -> char Stream.t -> char Stream.t
\end{ocamldoccode}
\index{decode@\verb`decode`}
\begin{ocamldocdescription}
Generic base64 decoding over a character stream.


\end{ocamldocdescription}




\label{val:XmlRpcBase64.make-underscoredecoding-underscoretable}\begin{ocamldoccode}
val make_decoding_table : encoding_table -> decoding_table
\end{ocamldoccode}
\index{make-underscoredecoding-underscoretable@\verb`make_decoding_table`}
\begin{ocamldocdescription}
Create a valid decoding table from an encoding one.


\end{ocamldocdescription}


\end{document}